<template>
  <div class="container">
    <web-view :src="service_url"
              v-if="url!=''"></web-view>
  </div>

</template>

<script>
import common from '@/assets/js/mmk_common.js'
export default {
  data () {
    return {
      service_url: '',
      user_data: {}
    };
  },
  methods: {
    getData () {
      wx.showLoading({
        title: "加载中", //提示的内容,
        mask: true //显示透明蒙层，防止触摸穿透
      });
      common.fly_post("api/v4_5/my_info_detail", {}, result => {
        let res = result.data;
        wx.hideLoading();
        if (res.status_code == 0) {
          wx.setStorageSync("user_data", res.data);
          this.write_url()
        } else {
          wx.showToast({
            title: res.message,
            icon: "none",
            duration: 2000,
            mask: true
          });
        }
      });
    },
    write_url () {
      let user_data = wx.getStorageSync('user_data');
      let url_str = `https://imxcx10.7x24cc.com/phone_webChat.html?accountId=N000000017052&chatId=eece42c0-5e11-4860-8843-9c0f62d7ea4a&nickName=${encodeURIComponent(user_data.realname && user_data.realname != '' ? user_data.realname : user_data.nickname)}&phone=${user_data.username}&visitorId=${`mmk_xcx_app_${user_data.id}`}`
      this.service_url = url_str
      console.log(this.service_url);

    }
  },
  onShow () {
    let that = this
    wx.getStorage({
      key: 'user_token',
      success: (res) => {
        this.getData()
      },
      fail: () => {
        wx.navigateTo({ url: '/pages/package_main/login/main' });
      },
      complete: () => { }
    })
  }
};
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
}
</style>


